package sebastiankerckhof.scene.transformation;

import sebastiankerckhof.math.Matrix4f;
import sebastiankerckhof.math.Vector3f;

public class Scale implements Transformation{
	Vector3f scale;
	public Scale(Vector3f v){
		this.scale = v;
	
	}
	
	@Override
	public Matrix4f invert(){
	 	return getInvertStep(1.0f);
	}
	
	@Override
	public Matrix4f getInvertStep(float step) {
		Vector3f s  = scale.scale(step);
		return new Matrix4f(
 				1.0f/s.x, 0.0f, 			0.0f, 			0.0f,
       0.0f, 			1.0f/s.y,  	0.0f, 			0.0f,
       0.0f, 			0.0f, 			1.0f/s.z, 	0.0f,
       0.0f, 			0.0f, 			0.0f, 			1.0f
       );
	}

	@Override
  public Matrix4f getMatrix() {
		return getMatrix(scale);
  }
	
	protected Matrix4f getMatrix(Vector3f scale){
		return new Matrix4f(
 				scale.x,  0.0f, 0.0f, 0.0f,
       0.0f, 	scale.y,  0.0f, 0.0f,
       0.0f, 	0.0f, scale.z, 	0.0f,
       0.0f, 	0.0f, 0.0f, 1.0f
       ); 
	}

	@Override
  public Matrix4f getStep(float step) {
			return getMatrix(scale.scale(step));
  }
	
	@Override
	public String toString(){
		return getMatrix().toString();
	}
}
